package com.lineage.server.serverpackets;

import com.lineage.server.model.Instance.L1NpcInstance;
import com.lineage.server.model.Instance.L1PcInstance;

public class S_NpcChat extends ServerBasePacket {
  private byte[] _byte;
  
  public S_NpcChat(L1NpcInstance npc, String chat) {
    this._byte = null;
    writeC(161);
    writeC(0);
    writeD(npc.getId());
    writeS(String.valueOf(String.valueOf(npc.getNameId())) + ": " + chat);
  }
  
  public S_NpcChat(int objid, String chat) {
    this._byte = null;
    writeC(161);
    writeC(0);
    writeD(objid);
    writeS(chat);
  }
  
  public S_NpcChat(L1NpcInstance npc, String chat, boolean name) {
    this._byte = null;
    writeC(161);
    writeC(0);
    writeD(npc.getId());
    writeS(
        String.valueOf(String.valueOf(name ? (String.valueOf(npc.getNameId()) + ": ") : "")) + 
        chat);
  }
  
  public S_NpcChat(L1NpcInstance npc, L1PcInstance pc, String chat) {
    this._byte = null;
    writeC(161);
    writeC(0);
    writeD(npc.getId());
    writeS(String.valueOf(String.valueOf(npc.getNameId())) + ": " + chat + "! " + pc.getName());
  }
  
  public byte[] getContent() {
    if (this._byte == null)
      this._byte = getBytes(); 
    return this._byte;
  }
  
  public String getType() {
    return getClass().getSimpleName();
  }
}
